package disjunction.extensions.view
{
	import flash.display.DisplayObject;
	import disjunction.View;

	/**
	 *
	 *
	 * @author Nick Wiggill
	 */
	
	public class DisplayObjectView extends View
	{
		/** 
		 * (abstract) Adds an entity view to the display processing list.
		 * Can be overridden to provide extra functionality (such as explicitly 
		 * adding a DisplayObject to the display list in AS3 or Pulpcore).*/
		public override function addEntity(entity:Object):void
		{
			var entityView:DisplayObject = createEntity(entity) as DisplayObject;
			_currentViewsByEntity[entity] = entityView;
			context.addChild(entityView);
			
			//ensure not visible yet, turn on when first render cycle comes round
			entityView.visible = false;
		}
		
		/** 
		 * (abstract) Removes an entity view from the display processing list.
		 * Can be overridden to provide extra functionality (such as explicitly 
		 * adding a DisplayObject to the display list in AS3 or Pulpcore).*/
		public override function removeEntity(entity:Object):void
		{
			context.removeChild(_currentViewsByEntity[entity] as DisplayObject);
			//destroyEntity(_currentViewsByEntity[entity]);
			//delete _currentViewsByEntity[entity];
		}
	}
}